import 'package:bmi_calculator/gender.dart';
import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'BMI Calculator',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new InputPage(),
    );
  }
}

class InputPage extends StatelessWidget {
  //顶部标题
  Widget _buildTitle() {
    return new Padding(
      padding: const EdgeInsets.only(left: 14.0, top: 50.0, bottom: 30.0),
      child: new Text(
        'BMI Calculator',
        style: new TextStyle(fontSize: 28.0, fontWeight: FontWeight.bold),
      ),
    );
  }

  //底部按钮
  Widget _buildBottom() {
    return new Container(
      height: 100.0,
      width: double.infinity,
      alignment: Alignment.center,
      child: new Switch(
        value: true,
        onChanged: (a) {},
      ),
    );
  }

  //独立卡片
  Widget _tempCard(String label) {
    return new Card(
      child: new Container(
        width: double.infinity, //无限宽
        height: double.infinity, //无限宽
        child: new Text(label),
      ),
    );
  }

  //中间卡片区域
  Widget _buildCard() {
    return Padding(
      padding: const EdgeInsets.only(left: 14.0, right: 14.0),
      child: new Row(
        children: <Widget>[
          new Expanded(
            child: new Column(
              children: <Widget>[
                new Expanded(child: new GenderCard()),
                new Expanded(child: _tempCard('体重'))
              ],
            ),
          ),
          new Expanded(
            child: _tempCard('身高'),
          )
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Padding(
        padding: MediaQuery.of(context).padding,
        child: new Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            _buildTitle(),
            new Expanded(
              child: _buildCard(),
            ),
            _buildBottom(),
          ],
        ),
      ),
    );
  }
}
